package com.service.bean.garbage;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 垃圾称重数据数据区
 * @author lj
 *
 */
public class GarbageData {
	/**
	 * 驾驶员编号
	 */
	public String driverNo;
	/**
	 * 收集区编号
	 */
	public String collectionId;
	/**
	 * 垃圾桶1编号
	 */
	public String firstTrashId;
	/**
	 * 垃圾桶1重量
	 */
	public String firstTrashWeight;
	/**
	 * 垃圾桶2编号
	 */
	public String secondTrashId;
	/**
	 * 垃圾桶2重量
	 */
	public String secondTrashWeight;
	/**
	 * 当天桶数
	 */
	public String trashNum;
	
	// 年月日时分秒
	public String year;
	public String month;
	public String day;
	public String hour;
	public String minute;
	public String second;
	/**
	 * 纬度
	 */
	public String latitude;
	/**
	 * 经度
	 */
	public String longtitude;
	
	public Date getGpsTime() {
		StringBuilder builder = new StringBuilder();
		Date date = null;
		builder.append(2000+Integer.parseInt(year, 16));
		builder.append("-");
		builder.append(Integer.parseInt(month, 16));
		builder.append("-");
		builder.append(Integer.parseInt(day, 16));
		builder.append(" ");
		builder.append(Integer.parseInt(hour, 16));
		builder.append(":");
		builder.append(Integer.parseInt(minute, 16));
		builder.append(":");
		builder.append(Integer.parseInt(second, 16));
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try {
			date = sdf.parse(builder.toString());
		} catch (ParseException e) {
			e.printStackTrace();
			return new Date();
		}
		Date now =  new Date();
		if (date.getTime() - now.getTime() > 5 * 60 * 1000) {
			return now;
		} else {
			return date;
		}
	}
	
}
